home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / mamesrc / src / amiga / video.h < prev   
Encoding:
C/C++ Source or Header  |  1999-12-03  |  7.0 KB  |  266 lines

  1. #ifndef VIDEO_H
  2. #define VIDEO_H
  3. /**************************************************************************
  4.  *
  5.  * Copyright (C) 1999 Mats Eirik Hansen (mats.hansen@triumph.no)
  6.  *
  7.  * $Id: video.h,v 1.1 1999/04/28 18:54:28 meh Exp meh $
  8.  *
  9.  * $Log: video.h,v $
  10.  * Revision 1.1  1999/04/28 18:54:28  meh
  11.  * Initial revision
  12.  *
  13.  *
  14.  *************************************************************************/
  15.  
  16. #include <exec/types.h>
  17.  
  18. #ifdef POWERUP
  19. #ifdef __PPC
  20. #include <powerup/gcclib/powerup_protos.h>
  21. #else
  22. #include <exec/execbase.h>
  23. #include <inline/ppc.h>
  24. extern struct Library *PPCLibBase;
  25. #endif
  26. #endif
  27.  
  28. #include <macros.h>
  29.  
  30. #define VA_UseScreen     (TAG_USER)
  31. #define VA_UseScreenReq  (TAG_USER+1)
  32. #define VA_Width         (TAG_USER+2)
  33. #define VA_Height        (TAG_USER+3)
  34. #define VA_Depth         (TAG_USER+4)
  35. #define VA_ModeID        (TAG_USER+5)
  36. #define VA_Buffers       (TAG_USER+6)
  37. #define VA_LessFlicker   (TAG_USER+7)
  38. #define VA_Title         (TAG_USER+8)
  39. #define VA_Menu          (TAG_USER+9)
  40. #define VA_NoRefresh     (TAG_USER+10)
  41. #define VA_FPS           (TAG_USER+11)
  42. #define VA_MaxColors     (TAG_USER+12)
  43. #define VA_AutoFrameSkip (TAG_USER+13)
  44. #define VA_MaxFrameSkip  (TAG_USER+14)
  45.  
  46. typedef enum
  47. {
  48.   None,
  49.   OutOfMemory,
  50.   OpenScreenFailed,
  51.   OpenWindowFailed
  52. } verror_t;
  53.  
  54. extern verror_t VError;
  55.  
  56. #define V_FrameHistory  4
  57.  
  58. struct Video;
  59.  
  60. struct VPixelArray
  61. {
  62.   struct Video  *Video;
  63.   struct BitMap *BitMap;
  64.   LONG          PixelFormat;
  65.   LONG          Size;
  66.   LONG          Width;
  67.   LONG          Height;
  68.   LONG          StartX;
  69.   LONG          StartY;
  70.   LONG          EndX;
  71.   LONG          EndY;
  72.   LONG          BytesPerRow;
  73.   LONG          BytesPerPixel;
  74.   LONG          PixelsSize;
  75.   UBYTE         *Pixels;
  76.   UBYTE         *DirtyLines;
  77.   LONG          BackgroundPen;
  78.   UBYTE         Palette[256][4];
  79. };
  80.  
  81. struct VVector
  82. {
  83.   WORD  X;
  84.   WORD  Y;
  85.   LONG  Pen;
  86. };
  87.  
  88. struct VVectorArray
  89. {
  90.   struct Video   *Video;
  91.   LONG           Size;
  92.   LONG           Width;
  93.   LONG           Height;
  94.   LONG           Length;
  95.   LONG           MaxLength;
  96.   struct VVector *Vectors;
  97.   LONG           BackgroundPen;
  98.   UBYTE          Palette[256][4];
  99. };
  100.  
  101. struct VDirectArray
  102. {
  103.   struct Video *Video;
  104.   LONG         Size;
  105.   LONG         Width;
  106.   LONG         Height;
  107.   LONG         BytesPerRow;
  108.   UBYTE        *Pixels;
  109.   LONG         BackgroundPen;
  110.   UBYTE        Palette[256][4];
  111. };
  112.  
  113. struct VFrame
  114. {
  115.   struct timeval Time;
  116.   struct timeval WaitTime;
  117.   LONG           Skipped;
  118. };
  119.  
  120. typedef enum
  121. {
  122.   WritePixelArray,
  123.   CustomC2P,
  124.   CGXHook,
  125.   WriteChunkyPixels,
  126.   BltBitMapRastPort
  127. } vpixelmode_t;
  128.  
  129. struct Video
  130. {
  131.   LONG                Left;
  132.   LONG                Top;
  133.   LONG                Width;
  134.   LONG                Height;
  135.   LONG                OffsetY;
  136.   ULONG               Buffers;
  137.   LONG                LessFlicker;
  138.   APTR                VisualInfo;
  139.   struct Menu         *Menu;
  140.   struct RastPort     *RastPort;
  141.   struct Window       *Window;
  142.   struct Hook         BackFillHook;
  143.   struct Screen       *Screen;
  144.   struct ScreenBuffer *ScreenBuffers[3];
  145.   struct MsgPort      ScreenBufferPort;
  146.   struct RastPort     ScreenBufferRP;
  147.   LONG                ScreenBufferChange;
  148.   LONG                CurrentScreenBuffer;
  149.   LONG                CyberMode;
  150.   vpixelmode_t        PixelMode;
  151.   ULONG               PixelFormat;
  152.   struct Rect32       FrameBox[3];
  153.   struct VPixelArray  *CurrentPixelArray;
  154.   struct VVectorArray *CurrentVectorArray;
  155.   struct CGXHook      *CGXHook;
  156.   struct RastPort     TempRastPort;
  157.   struct BitMap       *VectorBitMap;
  158.   struct RastPort     VectorRastPort;
  159.   LONG                VectorX;
  160.   LONG                VectorY;
  161.   LONG                VectorPen;
  162.   LONG                BackFillPen;
  163.   LONG                BackgroundPen;
  164.   ULONG               BackgroundColor;
  165.   ULONG               Palette[3*256+2];
  166.   ULONG               PackedPalette[256];
  167.   ULONG               CMAP[256];
  168.   APTR                Pointer;
  169.   APTR                BitMapLock;
  170.   UBYTE               *RemapBuffer;
  171.   struct timerequest  *TimerRequest;
  172.   struct MsgPort      TimerMsgPort;
  173.   struct Library      *TimerBase;
  174.   LONG                FPS;
  175.   LONG                CurrentFPS;
  176.   LONG                FrameSkip;
  177.   LONG                LimitSpeed;
  178.   LONG                AutoFrameSkip;
  179.   LONG                MaxFrameSkip;
  180.   LONG                CurrentFrame;
  181.   LONG                TotalFrames;
  182.   struct VFrame       Frames[V_FrameHistory];
  183.   struct timeval      TotalWaitTime;
  184. };
  185.  
  186.  
  187. struct Video *AllocVideo(Tag tags,...);
  188. void FreeVideo(struct Video *video);
  189. void VBeginFrame(struct Video *video, LONG bgpen, UBYTE *palette);
  190. void VEndFrame(struct Video *video);
  191. struct VPixelArray *VAllocPixelArray(struct Video *video, LONG width, LONG height, LONG dirty, ULONG *pixel_formats);
  192. void VFreePixelArray(struct VPixelArray *pixelarray);
  193. void VDrawPixelArray(struct VPixelArray *pixelarray);
  194. void VSetPixelFrame(struct VPixelArray *pixelarray);
  195. struct VVectorArray *VAllocVectorArray(struct Video *video, LONG width, LONG height, LONG length);
  196. void VFreeVectorArray(struct VVectorArray *vectorarray);
  197. void VDrawVectorArray(struct VVectorArray *vectorarray);
  198. void VSetVectorFrame(struct VVectorArray *vectorarray);
  199. struct VDirectArray *VAllocDirectArray(struct Video *video, LONG width, LONG height);
  200. void VFreeDirectArray(struct VDirectArray *directarray);
  201. void VSetDirectFrame(struct VDirectArray *directarray);
  202. void VSetFrameBox(struct Video *video, LONG sx, LONG sy, LONG ex, LONG ey);
  203. void VRefresh(struct Video *video);
  204. BOOL VBeginDirectDraw(struct Video *video, ULONG *bitmap, ULONG *byteperrow);
  205. void VEndDirectDraw(struct Video *video);
  206. void VSetFrameSkip(struct Video *video, LONG frameskip);
  207. LONG VGetFrameSkip(struct Video *video);
  208. LONG VGetFPS(struct Video *video);
  209. void VSetLimitSpeed(struct Video *video, LONG limitspeed);
  210. LONG VSaveILBM(struct Video *video, STRPTR filename);
  211.  
  212. static inline void VAddVector(struct VVectorArray *va, LONG x, LONG y, LONG p)
  213. {
  214.   if(va->Length < va->MaxLength)
  215.   {
  216.     va->Vectors[va->Length].X     = x;
  217.     va->Vectors[va->Length].Y     = y;
  218.     va->Vectors[va->Length++].Pen = p;
  219.   }
  220. }
  221.  
  222. static inline void VResetVectorArray(struct VVectorArray *va)
  223. {
  224.   va->Length = 0;
  225. }
  226.  
  227. static inline void VSetPixelArrayBox(struct VPixelArray *pa, LONG sx,
  228.                                      LONG sy, LONG ex, LONG ey)
  229. {
  230.   pa->StartX = sx;
  231.   pa->StartY = sy;
  232.   pa->EndX   = ex;
  233.   pa->EndY   = ey;
  234. }
  235.  
  236. static inline UBYTE *VGetPixelArrayAddr(struct VPixelArray *pa)
  237. {
  238.   return(pa->Pixels + pa->BytesPerPixel*pa->StartX + pa->BytesPerRow*pa->StartY);
  239. }
  240.  
  241. static inline UBYTE *VGetPixelArrayPointAddr(struct VPixelArray *pa, LONG x, LONG y)
  242. {
  243.   return(pa->Pixels + pa->BytesPerPixel*x + pa->BytesPerRow*y);
  244. }
  245.  
  246. static inline void VFlushPixelArray(struct VPixelArray *pa)
  247. {
  248. #if defined(POWERUP) && defined(__PPC)
  249.   PPCCacheFlush(pa, pa->Size);
  250.  
  251.   if(pa->PixelsSize)
  252.     PPCCacheFlush(pa->Pixels, pa->PixelsSize);
  253. #endif
  254. }
  255.  
  256. static inline void VInvalidPixelArray(struct VPixelArray *pa)
  257. {
  258. #if defined(POWERUP) && !defined(__PPC)
  259.   PPCCacheInvalidE(pa, pa->Size, CACRF_ClearD);
  260.  
  261.   if(pa->PixelsSize)
  262.     PPCCacheInvalidE(pa->Pixels, pa->PixelsSize, CACRF_ClearD);
  263. #endif
  264. }
  265. #endif
  266.